package com.example.javademo;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

public class TabFragment extends Fragment {
    private int position;
    private String title;

    public TabFragment(int position, String title) {
        this.position = position;
        this.title = title;
    }

    public TabFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_tab, container, false);

        TextView textView = view.findViewById(R.id.textView);
        textView.setText("这是 " + title + " 页面\n位置: " + position);

        return view;
    }
}
